package cn.felord.util;

import cn.felord.wepay.common.pay.Callback;
import cn.felord.wepay.common.pay.PostBusiness;
import cn.felord.wepay.common.proxy.ProxyPayCallback;
import cn.felord.wepay.wechat.service.WeChatPayCallback;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 回调处理   回调通过此来处理
 *
 * @author Dax
 * @version v1.0.0
 * @since 2017 /8/28  17:29
 */
public class CallbackUtil {

    private CallbackUtil() {
    }

    /**
     * Gets callback.
     *
     * @param request            the request
     * @param response           the response
     * @param appPayPostBusiness 微信请求商户后台 即为 notifyUrl 需要处理的业务  可实现此接口
     * @return the callback
     */
    public static Callback getCallback(HttpServletRequest request, HttpServletResponse response, PostBusiness appPayPostBusiness) {
        Callback weChatPayCallback = new WeChatPayCallback(request, response);
        ProxyPayCallback callback = new ProxyPayCallback(weChatPayCallback, appPayPostBusiness);
        return callback.initProxy();
    }

}
